import 'dart:io';
import 'package:lcapp/api/interface/comcon_api.dart';
import 'package:lcapp/api/request/response_data.dart';
import 'package:package_info_plus/package_info_plus.dart';

class BaseParam {
  static List? params;
  static int appStoreState = 1;
  static String appStoreVersion='1.0';
  static bool isCheck = false;
  static String version = '1.0.0';
  static String soldDesx = '不能发布品类、年份、等级、库存地、价格完全相同的商品';
  static String zixunDesx = '相关内容来源于网络，目的在于传递更多信息，文中建议仅供参考';
  static String? fabuSoldURL; //发布售卖操作视频
  static String? fabuVideoURL;//发布视频操作视频

  static getParams()async{
    ResponseData res = await CommonAPI.getBaseParams();
    if(res.code==200){
      params = res.data??[];
      for (var element in params!) {
        if(element['code']=='APP_STORE_STATE'){
          appStoreState = int.parse(element['value']??'1');
        }else if(element['code']=='APP_STORE_VERSIION'){
        appStoreVersion = element['value']??'1.0';
        }else if(element['code']=='MERCHANDISE_ADVICE'){
          soldDesx = element['value']??'不能发布品类、年份、等级、库存地、价格完全相同的商品';
        }else if(element['code'] == 'ZIXUN_ ADVICE'){
          zixunDesx = element['value']??'相关内容来源于网络，目的在于传递更多信息，文中建议仅供参考';
        }else if(element['code'] == 'PUBLISH_SOLD_URL'){
          fabuSoldURL = element['value'];
        }else if(element['code'] == 'PUBLISH_VIDEO_URL'){
          fabuVideoURL = element['value'];
        }
      }
      PackageInfo packageInfo = await PackageInfo.fromPlatform();
      version = packageInfo.version;
      if(appStoreState==2&&appStoreVersion==version&&Platform.isIOS){
        isCheck = true;
      }
    }
  }
}